package com.it.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
// TODO SpringMVC (4)、原生API对象的操作
/**
 *  【说明】：在形参列表获取原生API
 *  【支持参数】：
 *          1、HttpServletRequest、HttpServletResponse 获取请求\响应对象
 *          2、HttpSession\ServletContent获取会话对象
 *          3、InputStream\Reader\OutputStream\Writer 获取IO流
 *          4、@PathVariable 接收路径传参参数
 *          5、@RequestParam 注解接受参数
 *          6、@RequestHeader 接收请求头参数
 *          7、@CookieValue  获取cookie
 *          8、@RequestBody  接收JSON格式参数
 */

@Controller
@RequestMapping("/orig")
@ResponseBody
public class springmvc04 {
    // /orig/data1?username=admin&passwrod=admin123
    @GetMapping("data1")
    public String data1(HttpServletRequest request, HttpServletResponse response) {
        String username = request.getParameter("username");
        String passwrod = request.getParameter("passwrod");
        return username + " " + passwrod;
    }
}
